
#include "Game.h"


/*
-----------------------
-----------------------
*/

CGame_ActionTip::CGame_ActionTip()
{
	m_bShow = FALSE ;
}

CGame_ActionTip::~CGame_ActionTip()
{
	
}

void CGame_ActionTip::Show(CEntityManager* pManager, 
						PDWORD dwtab, 
						INT ix, INT iy, 
						DWORD Time, 
						DWORD Round, 
						DWORD dwPri)
{
	if(!m_bShow)
	{
		m_bShow = TRUE;
		m_SprTab = dwtab;
		m_Round = (INT)Round -1;
		m_TipEjectTime = GetTabIDNum(m_SprTab)*C_GAME_FRAME_TIME;
		m_TipTime 	=m_TipEjectTime + Time;
		m_TimeType =  eClockSystem;
		m_TipTimeStart = GetTime((GmClockType)m_TimeType) ;
		m_SprCnt = 0;
		
		SetPriority(dwPri);
		SetLayerID(eLayUI);
		SetPaletteID(ePalUI);
		SetCoordinate(ix, iy);
		SetManager(pManager);
		Enter();
	}
}


INT CGame_ActionTip::Execute()
{
	Update();
	return TRUE ;
}

void CGame_ActionTip::Update()
{
	if(!m_bShow)
		return ;

	if(GetTime((GmClockType)m_TimeType) < m_TipTimeStart + m_TipTime)
	{
		if(m_SprCnt <  (INT)GetTabIDNum(m_SprTab) -1 )
		{
			SetSprID(GetTabIDByIndex(m_SprTab, m_SprCnt));
			CSprite::Update();
			m_SprCnt++;
		}
		else if(m_Round > 0)
		{
			m_Round--;
			m_SprCnt = 0;
		}
	}
	else
	{
		Del();
	}
}

void CGame_ActionTip::Del()
{
	if(m_bShow)
	{
		m_bShow = FALSE;
		CSprite::Del();
		Out();
	}
}

BOOL CGame_ActionTip::IsEnd()
{
	if(GetTime((GmClockType)m_TimeType) > m_TipTimeStart + m_TipTime + 300)
	{
		return TRUE;
	}

	return FALSE ;
}




